package com.vm.utils;

import com.wwtscapp.apk.R;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class CityDialog {
	Context context;
	Dialogcallback dialogcallback;
	Dialog dialog;
	Button btn_confirm;
	Button btn_cancel;
	CityPicker cityPicker;

	public CityDialog(Context context) {
		this.context = context;
		dialog = new Dialog(context, R.style.citydialog);
		dialog.setContentView(R.layout.citydialog);
		init();
	}

	public void init() {
		cityPicker = (CityPicker) dialog.findViewById(R.id.citypicker);
		btn_confirm = (Button) dialog.findViewById(R.id.btn_confirm);
		btn_cancel = (Button) dialog.findViewById(R.id.btn_cancel);
		btn_confirm.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				dialogcallback.dialogdo(cityPicker.getProvince(),
						cityPicker.getCity(), cityPicker.getCouny(),cityPicker.getCity_code_string());
				dismiss();
			}
		});
		btn_cancel.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				dismiss();
			}
		});
		// String city = cityPicker.getCity_string();
	}

	public interface Dialogcallback {
		public void dialogdo(String string, String string2, String string3,String string4);
	}

	public void setDialogCallback(Dialogcallback dialogcallback) {
		this.dialogcallback = dialogcallback;
	}

	public void dismiss() {
		dialog.dismiss();
	}

	public void show() {
		dialog.show();
	}
}